package com.lin.blog.controller;

import com.lin.blog.service.IQiNiuService;
import com.lin.utils.Result;
import com.qiniu.common.QiniuException;
import com.qiniu.util.Auth;
import com.qiniu.util.StringMap;
import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @program: blog
 * @description: 七牛云控制类
 * @author: Lin
 * @create: 2020-04-03 12:28
 **/
@Api(tags = "七牛云接口")
@RestController
@RequestMapping("/qiniu")
public class QiNiuController {

    @Autowired
    private IQiNiuService qiNiuService;


    @GetMapping("/getToken")
    @RequiresUser
    public Result getToken() {
        return qiNiuService.getToken();
    }



    @PostMapping("/upload")
    @RequiresUser
    public Result upload(@RequestParam("file") MultipartFile multipartFile) throws IOException {
        return qiNiuService.uploadFile(multipartFile);
    }



}
